<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
  <meta charset="utf-8">
  <title>学生管理(runoob.com)</title>

  <!--    elementplus-->
  <link rel="stylesheet" th:href="@{/js/element-plus/index.css}" href="/js/element-plus/index.css">

</head>

<body>
<div id="app" class="demo">
  <div class="login-container">
    <el-card class="login-card">
      <div class="login-title">登录</div>
      <el-form ref="loginForm" :model="loginForm" :rules="loginRules" label-width="80px">
        <el-form-item label="用户名" prop="username">
          <el-input v-model="loginForm.username" placeholder="请输入用户名"></el-input>
        </el-form-item>
        <el-form-item label="密码" prop="password">
          <el-input type="password" v-model="loginForm.password" placeholder="请输入密码"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="login">登录</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</div>
<script th:src="@{/js/vue.global.min.js}" src="/js/vue.global.min.js"></script>
<script th:src="@{/js/axios.min.js}"  src="/js/axios.min.js"></script>
<!-- import JavaScript -->
<script th:src="@{/js/element-plus/index.full.js}" src="/js/element-plus/index.full.js"></script>
<script>
  const HelloVueApp = {
    data() {
      return {
        loginForm: {
          username: '',
          password: '',
        },
        loginRules: {
          username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
          password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
        },
      }
    },
    methods: {
      login() {
        // 实现登录逻辑，可以通过调用 API 或其他方式验证用户信息
        console.log('Login Clicked');
        debugger
        this.$refs.loginForm.validate(valid => {
          if (valid) {
            // 在这里处理登录逻辑，例如发送登录请求到服务器
            console.log('登录成功');
            window.location.href="/tomain";
          } else {
            console.log('验证失败');
            return false;
          }
        });

      },
    },
    mounted() {
    }

  }
  const app = Vue.createApp(HelloVueApp);
  app.use(ElementPlus);
  app.mount("#app");
</script>
<style scoped>
  .login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
  }

  .login-card {
    width: 400px;
  }

  .login-title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 20px;
    text-align: center;
  }
</style>
</body>

</html>